package com.github.catvod.parser;

import android.util.Base64;
import com.github.catvod.crawler.SpiderDebug;
import com.github.catvod.spider.merge.CE;
import com.github.catvod.spider.merge.fP;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import org.json.JSONObject;

public class JsonBasic {
  public static HashMap<String, String> getReqHeader(String paramString) {
    HashMap<Object, Object> hashMap = new HashMap<Object, Object>();
    if (paramString.contains("cat_ext")) {
      try {
        int i = paramString.indexOf("cat_ext=");
        int j = paramString.indexOf("&", i);
        String str2 = paramString.substring(i + 8, j);
        String str1 = new String();
        this(Base64.decode(str2, 10));
        StringBuilder stringBuilder = new StringBuilder();
        this();
        stringBuilder.append(paramString.substring(0, i));
        stringBuilder.append(paramString.substring(j + 1));
        paramString = stringBuilder.toString();
        JSONObject jSONObject = new JSONObject();
        this(str1);
        if (jSONObject.has("header")) {
          JSONObject jSONObject1 = jSONObject.optJSONObject("header");
          Iterator<String> iterator = jSONObject1.keys();
          while (iterator.hasNext()) {
            String str = iterator.next();
            hashMap.put(str, jSONObject1.optString(str, ""));
          } 
        } 
        hashMap.put("url", paramString);
      } finally {}
    } else {
      hashMap.put("url", paramString);
    } 
    return (HashMap)hashMap;
  }
  
  public static JSONObject parse(LinkedHashMap<String, String> paramLinkedHashMap, String paramString) {
    try {
      SpiderDebug.log("Load Json Parse Basic...");
      if (paramLinkedHashMap.size() > 0)
        for (String str : paramLinkedHashMap.keySet()) {
          HashMap<String, String> hashMap = getReqHeader(paramLinkedHashMap.get(str));
          try {
            String str1 = hashMap.get("url");
            hashMap.remove("url");
            StringBuilder stringBuilder = new StringBuilder();
            this();
            stringBuilder.append(str1);
            stringBuilder.append(paramString);
            SpiderDebug.log(stringBuilder.toString());
            stringBuilder = new StringBuilder();
            this();
            stringBuilder.append(str1);
            stringBuilder.append(paramString);
            JSONObject jSONObject = CE.BQ(paramString, fP.oq(stringBuilder.toString(), hashMap));
            return jSONObject;
          } finally {
            str = null;
            SpiderDebug.log((Throwable)str);
          } 
        }  
    } finally {
      paramLinkedHashMap = null;
    } 
  }
}


/* Location:              /Users/hetaiyi/Desktop/my/tech/java/study/aa/temp/temp.jar!/com/github/catvod/parser/JsonBasic.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */